package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.util.Scanner;

public class NativeDriveruUsed {
	public static void main(String[] args) {
		int id;
		String name;
		float salary;
		try {
			Class.forName("oracle.jdbc.driver.OracleDriver");
			Connection con = DriverManager.getConnection(
					"jdbc:oracle:thin:@10.23.245:1521:orcl", "scott", "tiger");
			System.out.println("Driver Connected successfully.");

			Scanner sc = new Scanner(System.in);

			System.out.println("Enter id:");
			id = sc.nextInt();

			System.out.println("Enter Name:");
			name = sc.next();

			System.out.println("Enter Salary:");
			salary = sc.nextFloat();

			Statement stmt = con.createStatement();
			System.out.println("Statement Created successfully.");

			stmt.executeUpdate("INSERT INTO myTable VALUES ( " + id + ",'"
					+ name + "', " + salary + ")");

			System.out.println("Record inserted successfully.");

			stmt.close();
			con.close();

		} catch (Exception e) {
			System.out.println(e.toString());
		}
	}
}
